#include<iostream>
using namespace std;
int n,k,x[20];

bool isprime(int num){
    if ( num==2 || num==3 ) return true;
    if ( num==0 || !num&1 ) return false;
    for (int i = 2; i*i <= num; i++)
    {
        if (num%i==0) return false;        
    }
    return true;
}

int rule(int k,int cur,int begin,int end){
    if(k==0)return isprime(cur);
    int count = 0;
    for (int i = begin; i <= end; i++)
    {
        count += rule(k-1,cur+x[i],i+1,end);
    }
    return count;
}

int main(int argc, char const *argv[])
{
    scanf("%d %d",&n,&k);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&x[i]);
    }
    
    printf("%d",rule(k,0,0,n-1));

    return 0;
}
